import 'package:get/get.dart';
import 'package:xin_nuo_pda/base/BaseController.dart';
import 'package:xin_nuo_pda/http/api/eqp_api.dart';

import 'EquipmentRepairListState.dart';

class EquipmentRepairListController extends BaseController {
  final EquipmentRepairListState state = EquipmentRepairListState();

  void updateSelectDefectValue(var str) {
    state.selectDefectValue = str;
    update([state.dropDownId]);
    initList();
  }

  @override
  void onInit() {
    super.onInit();
    state.where  = Get.arguments;
    switch(state.where){
      case "EQP":
        state.title = "设备维修列表";
        break;
      case "PE":
        state.title = "PE处理";
        break;
      case "QA":
        state.title = "QA处理";
        break;
    }
  }

  @override
  void onReady() {
    super.onReady();
    initList();
  }

  initList() async{
    String status = '';
    switch(state.where){
      case "EQP":
        status = "REPAIR";
        break;
      case "PE":
        status = "PE";
        break;
      case "QA":
        status = "QA";
        break;
    }
    // ,'STATUS': state.selectDefectValue
    Map<String, dynamic> params = {'EQUIPMENTID': state.eqpController.text,'EQUIPMENTSTATE' : status};
    var result = await EqpApi.getRepairList(canelToken,params: params);
    if(result.ok){
        state.repairList = result.data?.rEPAIRLIST ?? [];
        update([state.repairListId]);
    }
  }
}
